﻿using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.Text;
using Components;

namespace ServiceHelper.Util
{
    /// <summary>
    /// 类似于HttpContext
    /// </summary>
    public class ServerContext
    {
        public static string AuthKey
        {
            get
            {
                if (OperationContext.Current != null)
                {
                    return OperationContext.Current.IncomingMessageHeaders.GetHeader<string>("AuthKey", Globals.ProductUrl);
                }

                return null;
            }
        }

        public static string UserCode
        {
            get { return Context.GetUserCode(AuthKey); }
        }

        public static string GetComDesc
        {
            get
            {
                return Context.GetAppByUserCode(UserCode);
            }
        }

        public static string ComCode
        {
            get
            {
                return Context.GetComcode(AuthKey);
            }
        }
    }
}
